#### Event Data on Armed Conflict and Security: New Perspectives, Old Challenges, and Some Solutions

### Replication Script for Figures 2 & 3
## scripts run on:
# R version 2.13.0 (2011-04-13)
# Copyright (C) 2011 The R Foundation for Statistical Computing
# ISBN 3-900051-07-0
# Platform: x86_64-pc-mingw32/x64 (64-bit)

## For questions or clarifications, contact c.ickler@fu-berlin.de

## load data: Somalia 1997 to 2009
SOM<-read.csv2(".../SOM_EventsbyYearmon.csv",header=T,fill=T,quote = '"',sep=";",dec=",", strip.white=T, blank.lines.skip=T,comment.char="", stringsAsFactors = FALSE)
str(SOM)

# build time-series
SOM_EDACS <- ts(SOM[,2],start=1997,freq=12)
SOM_ACLED <-ts(SOM[,3],start=1997,freq=12)
SOM_UCDP <-ts(SOM[,4],start=1997,freq=12)

# smooth data
SOM_EDACS <- lowess(SOM_EDACS,f=.1)
SOM_ACLED <- lowess(SOM_ACLED,f=.1)
SOM_UCDP <- lowess(SOM_UCDP,f=.1)

# plot data
plot(SOM_EDACS,xlab="Time",ylab="Violent Events / Event Days",ylim=c(0,80),col="#4C4C4C",type="l",lty=13,lwd = 2,xlim=c(1997,2009))
lines(SOM_ACLED, col="#888888",lwd = 2,lty=1343)
lines(SOM_UCDP, col="#AEAEAE",lwd = 2,lty=4)
library(Hmisc);minor.tick(ny=4, nx=2)

# plot legend
legend("topleft", c("ACLED Events","EDACS Event Days","UCDP-GED Events"), col=c("#888888","#4C4C4C","#AEAEAE"), lty = c(1343,13,4), lwd=2, bty="n")
text(1996.8, 69, "Total:",adj = 0)
text(1996.8, 65, "ACLED: 3896 violent events,", adj = 0)
text(1996.8, 61.6, "34+ sources used", adj = 0)
text(1996.8, 57, "EDACS: 2372 event days,", adj = 0)
text(1996.8, 53.6, "74+ sources used", adj = 0)
text(1996.8, 49, "UCDP-GED: 1094 events,", adj = 0)
text(1996.8, 45.6, "54+ sources used", adj = 0)


## load data: Sierra Leone 1997 to 2004
SIE<-read.csv2(".../SIE_EventsbyYearmon.csv",header=T,fill=T,quote = '"',sep=";",dec=",", strip.white=T,blank.lines.skip=T, comment.char="", stringsAsFactors = FALSE)
str(SIE)

# build time-series
SIE_EDACS <- ts(SIE[,2],start=1997,freq=12)
SIE_ACLED <-ts(SIE[,3],start=1997,freq=12)
SIE_UCDP <-ts(SIE[,4],start=1997,freq=12)

# smooth data
SIE_EDACS <- lowess(SIE_EDACS,f=.1)
SIE_ACLED <- lowess(SIE_ACLED,f=.1)
SIE_UCDP <- lowess(SIE_UCDP,f=.1)

# plot data
plot(SIE_EDACS,xlab="Time",ylab="Violent Events / Event Days",ylim=c(0,40), col="#4C4C4C",type="l", lty=13,lwd=2,xlim=c(1997,2003))
lines(SIE_ACLED, col="#888888",lwd = 2,lty=1343)
lines(SIE_UCDP, col="#AEAEAE",lwd = 2,lty=4)
library(Hmisc);minor.tick(ny=4, nx=2)

# plot legend
legend("topright", c("ACLED Events","EDACS Event Days","UCDP-GED Events"), col=c("#888888","#4C4C4C","#AEAEAE"), lty = c(1343,13,4), lwd=2, bty="n")
text(2000.83, 34, "Total:",adj = 0)
text(2000.83, 32, "ACLED: 1287 violent events,", adj = 0)
text(2000.83, 30.4, "53+ sources used", adj = 0)
text(2000.83, 28, "EDACS: 276 event days,", adj = 0)
text(2000.83, 26.4, "28+ sources used", adj = 0)
text(2000.83, 24, "UCDP-GED: 156 events,", adj = 0)
text(2000.83, 22.4, "28+ sources used", adj = 0)